package com.lxitedu.tool;

import java.util.Date;

import com.huawei.api.SMEntry;
import com.huawei.api.SMException;

public class SMSTool {
	private static final String DB_PASSWORD = "guanlan@)!!";
	private static final String DB_USER_NAME = "guanlan";
	private static final String DB_NAME = "10.99.1.116";
	private static final String SOURCE_ADDR= "1065730102420024";
	public static void init() {
		SMEntry.init(DB_NAME, DB_USER_NAME, DB_PASSWORD);
		
	}
	public static void sendMessage(String destAddr, String content) {
		java.util.Date atTime = new Date();
		int needStateReport = 0;
		String serviceID = "123456";
		String feeType = "01";
		String feeCode = "20";
		try {
			int count = SMEntry.submitShortMessage(atTime, SOURCE_ADDR,
					destAddr, content, needStateReport, serviceID, feeType,
					feeCode);
		} catch (SMException e1) {
			System.out.println("发送短信失败,请检查是否服务器是否正常或者手机号码正确 号码为 <"+destAddr+ "> \t 内容是<<"+content+">>");
		}
		
	}
	public static void cleanUp()   {
		try {
			SMEntry.cleanUp();
		} catch (SMException e) {
			e.printStackTrace();
		}
		
	}
	
}
